package com.pms.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pms.common.annotation.Log;
import com.pms.common.core.controller.BaseController;
import com.pms.common.core.domain.AjaxResult;
import com.pms.common.enums.BusinessType;
import com.pms.system.domain.PmsGuestroomItem;
import com.pms.system.service.IPmsGuestroomItemService;
import com.pms.common.utils.poi.ExcelUtil;
import com.pms.common.core.page.TableDataInfo;

/**
 * 客房类型Controller
 * 
 * @author 达瓦里氏
 * @date 2023-03-04
 */
@RestController
@RequestMapping("/system/PmsGuestroomItem")
public class PmsGuestroomItemController extends BaseController
{
    @Autowired
    private IPmsGuestroomItemService pmsGuestroomItemService;

    /**
     * 查询客房类型列表
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(PmsGuestroomItem pmsGuestroomItem)
    {
        startPage();
        List<PmsGuestroomItem> list = pmsGuestroomItemService.selectPmsGuestroomItemList(pmsGuestroomItem);
        return getDataTable(list);
    }

    /**
     * 查询客房类型列表List
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomItem:Itemlist')")
    @GetMapping("/Itemlist")
    public List<PmsGuestroomItem> Itemlist(PmsGuestroomItem pmsGuestroomItem)
    {
        List<PmsGuestroomItem> list = pmsGuestroomItemService.selectPmsGuestroomItemList(pmsGuestroomItem);
        return list;
    }

    /**
     * 导出客房类型列表
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomItem:export')")
//    @Log(title = "客房类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PmsGuestroomItem pmsGuestroomItem)
    {
        List<PmsGuestroomItem> list = pmsGuestroomItemService.selectPmsGuestroomItemList(pmsGuestroomItem);
        ExcelUtil<PmsGuestroomItem> util = new ExcelUtil<PmsGuestroomItem>(PmsGuestroomItem.class);
        util.exportExcel(response, list, "客房类型数据");
    }

    /**
     * 获取客房类型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pmsGuestroomItemService.selectPmsGuestroomItemById(id));
    }

    /**
     * 新增客房类型
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomItem:add')")
//    @Log(title = "客房类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsGuestroomItem pmsGuestroomItem)
    {
        return toAjax(pmsGuestroomItemService.insertPmsGuestroomItem(pmsGuestroomItem));
    }

    /**
     * 修改客房类型
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomItem:edit')")
//    @Log(title = "客房类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsGuestroomItem pmsGuestroomItem)
    {
        return toAjax(pmsGuestroomItemService.updatePmsGuestroomItem(pmsGuestroomItem));
    }

    /**
     * 删除客房类型
     */
//    @PreAuthorize("@ss.hasPermi('system:PmsGuestroomItem:remove')")
//    @Log(title = "客房类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pmsGuestroomItemService.deletePmsGuestroomItemByIds(ids));
    }
}
